
clear all

#delimit ;
*  PSID DATA CENTER *****************************************************
   JOBID            : 296256                            
   DATA_DOMAIN      : IND                               
   USER_WHERE       : NULL                              
   FILE_TYPE        : All Individuals Data              
   OUTPUT_DATA_TYPE : ASCII                             
   STATEMENTS       : do                                
   CODEBOOK_TYPE    : PDF                               
   N_OF_VARIABLES   : 51                                
   N_OF_OBSERVATIONS: 43427                             
   MAX_REC_LENGTH   : 176                               
   DATE & TIME      : August 8, 2021 @ 14:40:30
*************************************************************************
;

infix
      ER30000              1 - 1           ER30001              2 - 5           ER30002              6 - 8     
      ER33401              9 - 13          ER33402             14 - 15          ER33403             16 - 17    
 long ER33438             18 - 23          ER33501             24 - 28          ER33502             29 - 30    
      ER33503             31 - 32     long ER33547             33 - 37          ER33601             38 - 41    
      ER33602             42 - 43          ER33603             44 - 45     long ER33639             46 - 50    
      ER33701             51 - 55          ER33702             56 - 57          ER33703             58 - 59    
 long ER33742             60 - 64          ER33801             65 - 69          ER33802             70 - 71    
      ER33803             72 - 73     long ER33849             74 - 78          ER33901             79 - 83    
      ER33902             84 - 85          ER33903             86 - 87     long ER33951             88 - 92    
      ER34001             93 - 97          ER34002             98 - 99          ER34003            100 - 101   
 long ER34046            102 - 106         ER34101            107 - 111         ER34102            112 - 113   
      ER34103            114 - 115    long ER34155            116 - 120         ER34201            121 - 125   
      ER34202            126 - 127         ER34203            128 - 129    long ER34269            130 - 134   
      ER34301            135 - 139         ER34302            140 - 141         ER34303            142 - 143   
 long ER34414            144 - 148         ER34501            149 - 153         ER34502            154 - 155   
      ER34503            156 - 157    long ER34651            158 - 162         ER34701            163 - 167   
      ER34702            168 - 169         ER34703            170 - 171    long ER34864            172 - 176   
using ./RawData/xsection_weights.txt, clear 
;
label variable ER30000         "RELEASE NUMBER"                           ;
label variable ER30001         "1968 INTERVIEW NUMBER"                    ;
label variable ER30002         "PERSON NUMBER                         68" ;
label variable ER33401         "1997 INTERVIEW NUMBER"                    ;
label variable ER33402         "SEQUENCE NUMBER                       97" ;
label variable ER33403         "RELATION TO HEAD                      97" ;
label variable ER33438         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  97" ;
label variable ER33501         "1999 INTERVIEW NUMBER"                    ;
label variable ER33502         "SEQUENCE NUMBER                       99" ;
label variable ER33503         "RELATION TO HEAD                      99" ;
label variable ER33547         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  99" ;
label variable ER33601         "2001 INTERVIEW NUMBER"                    ;
label variable ER33602         "SEQUENCE NUMBER                       01" ;
label variable ER33603         "RELATION TO HEAD                      01" ;
label variable ER33639         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  01" ;
label variable ER33701         "2003 INTERVIEW NUMBER"                    ;
label variable ER33702         "SEQUENCE NUMBER                       03" ;
label variable ER33703         "RELATION TO HEAD                      03" ;
label variable ER33742         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  03" ;
label variable ER33801         "2005 INTERVIEW NUMBER"                    ;
label variable ER33802         "SEQUENCE NUMBER                       05" ;
label variable ER33803         "RELATION TO HEAD                      05" ;
label variable ER33849         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  05" ;
label variable ER33901         "2007 INTERVIEW NUMBER"                    ;
label variable ER33902         "SEQUENCE NUMBER                       07" ;
label variable ER33903         "RELATION TO HEAD                      07" ;
label variable ER33951         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  07" ;
label variable ER34001         "2009 INTERVIEW NUMBER"                    ;
label variable ER34002         "SEQUENCE NUMBER                       09" ;
label variable ER34003         "RELATION TO HEAD                      09" ;
label variable ER34046         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  09" ;
label variable ER34101         "2011 INTERVIEW NUMBER"                    ;
label variable ER34102         "SEQUENCE NUMBER                       11" ;
label variable ER34103         "RELATION TO HEAD                      11" ;
label variable ER34155         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  11" ;
label variable ER34201         "2013 INTERVIEW NUMBER"                    ;
label variable ER34202         "SEQUENCE NUMBER                       13" ;
label variable ER34203         "RELATION TO HEAD                      13" ;
label variable ER34269         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  13" ;
label variable ER34301         "2015 INTERVIEW NUMBER"                    ;
label variable ER34302         "SEQUENCE NUMBER                       15" ;
label variable ER34303         "RELATION TO HEAD                      15" ;
label variable ER34414         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  15" ;
label variable ER34501         "2017 INTERVIEW NUMBER"                    ;
label variable ER34502         "SEQUENCE NUMBER                       17" ;
label variable ER34503         "RELATION TO REFERENCE PERSON          17" ;
label variable ER34651         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  17" ;
label variable ER34701         "2019 INTERVIEW NUMBER"                    ;
label variable ER34702         "SEQUENCE NUMBER                       19" ;
label variable ER34703         "RELATION TO REFERENCE PERSON          19" ;
label variable ER34864         "CORE/IMM INDIVIDUAL CROSS-SECTION WT  19" ;



do ./RawData/xsection_weights_formats.do ;
#delimit cr

// RETROSPECTIVE FATHER OCC 

	rename ER33438 xsection_weight_1997
	rename ER33547 xsection_weight_1999
	rename ER33639 xsection_weight_2001
	rename ER33742 xsection_weight_2003
	rename ER33849 xsection_weight_2005
	rename ER33951 xsection_weight_2007
	rename ER34046 xsection_weight_2009
	rename ER34155 xsection_weight_2011
	rename ER34269 xsection_weight_2013
	rename ER34414 xsection_weight_2015

// CREATE SON_ID, KEEP PERTINENT VARS, SAVE
	ren ER30001 famid
	ren ER30002 personnumber

	gen son_id = famid*1000 + personnumber
	label var son_id "Child 1968 ID"
	duplicates report son_id //no duplicates
	
	keep son_id famid personnumber xsection_weight*
		
	sort son_id 
	compress
	save ./RawData/xsection_weights_info, replace



